//
//  WishListTableViewCell.swift
//  CJXSwiftStoryboard
//
//  Created by CJX on 2016/10/28.
//  Copyright © 2016年 caijianxi. All rights reserved.
//

import UIKit

protocol WishListTableViewCellDelegate {
    func viewButtonDelegateWithID(_ id:String,imageStr:String)
    func deleteButtonDelegateWithID(_ id:String)
}

class WishListTableViewCell: UITableViewCell {

    var delegate : WishListTableViewCellDelegate?
    
    @IBOutlet weak var myImageView: UIImageView!
    
    @IBOutlet weak var nameLabel: UILabel!
    
    @IBOutlet weak var viewButton: UIButton!
    
    @IBOutlet weak var deleteButton: UIButton!
    
    
    var model:WishListModel?{
        didSet{
            myImageView.sd_setImage(with: URL(string: (model?.products_image!)!), placeholderImage: nil)
            nameLabel.text = model?.products_name
        }
    }
    
    @IBAction func viewButtonClick(_ sender: AnyObject) {
        
        self.delegate?.viewButtonDelegateWithID((model?.products_id)!, imageStr: (model?.products_image)!)
    }
    @IBAction func deleteButtonClick(_ sender: AnyObject) {
        self.delegate?.deleteButtonDelegateWithID((model?.products_id)!)
        
    }
    

    override func awakeFromNib() {
        super.awakeFromNib()

    
        myImageView.contentMode = .scaleAspectFit
        myImageView.clipsToBounds = true
    
    }

    override func setSelected(_ selected: Bool, animated: Bool) {
        super.setSelected(selected, animated: animated)

        // Configure the view for the selected state
    }
    
}
